package jsen.tool.ddd.demo.domain.parking.spec.loc;

import jsen.tool.ddd.adapter.infrastructure.specification.ISpecification;
import jsen.tool.ddd.adapter.infrastructure.specification.base.SpecContext;
import jsen.tool.ddd.demo.domain.parking.Location;

/**
 * @author jsen
 * @date 2021/10/6
 */
public class LocationSpec implements ISpecification<Location> {
    @Override
    public boolean isSatisfiedBy(SpecContext<Location> t) {
        Location location = t.getData();
        if (location.getW() <= 0 || location.getH() <= 0 || location.getX() <= 0 || location.getY() <= 0) {
            t.addError("location", "位置不合法");
            return false;
        }
        return true;
    }
}
